package com.miracle9.game.thread;

import com.miracle9.game.service.AdminService;
import javax.annotation.PostConstruct;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("backupThread")
public class BackupThread extends Thread
{
  private Logger logger = Logger.getLogger(BackupThread.class);
  @Autowired
  private AdminService adminService;
  
  @PostConstruct
  public void backupThreadStart()
  {
    start();
  }
  
  public void run()
  {
    try
    {
      for (;;)
      {
        sleep(21600000L);
        this.adminService.pubBack("/backup/");
        this.logger.info("定时备份执行成功！");
      }
    }
    catch (Exception e)
    {
      this.logger.error("", e);
    }
  }
}
